#include "cascade_bagging.h"

double cascade_bagging::predict(double * alpha, double * p, int n) {
	int k = n;
	for(int i = 0; i < n; i++) {
		if(p[i] < 0.5) {
			k = i;
			break;
		}
	}

	double result;
	if(k == n) {
		result = 1;
	} else {
		result = 0.5 * k / (double) n;
	}
	return result;
}

string cascade_bagging::get_type() {
	return "cascade_bagging";
}

string cascade_gradual_bagging::get_type() {
	return "cascade_gradual_bagging";
}

void cascade_gradual_bagging::update_distribution(double alpha, double * y, double * p, int l, double * d_t, double * d_t1) {
	gradual_update_distribution(y, p, l, d_t, d_t1);
}
